<template>
<!-- 用户反馈 begin -->
<div class="main main-school" id="main_user_feedback">
	<div class="main-hd">
		<h2>数据标签</h2>
		
	</div>
	<div id="vueTest" class="main-bd">
		<div class="content-wrap">
			<p class="form form-inline">
				<DatePicker type="date" format="yyyy-MM-dd" :options="disDate" @on-change="timeChange" placeholder="请选择时间" style="width: 200px"></DatePicker>
				<Select v-model="platformId" style="width: 200px;">
	        		<Option v-for="item in platformList" :value="item.id">{{item.platformName}}</Option>
	        	</Select>
			</p>
			<!-- 商户列表 begin -->
			<div>
				<div>
					<div v-if="platformId == '' || platformId == null">请选择你要操作的时间跟平台！</div>
					<div  v-else>
					<table class="table table-hover table-condensed" border>
						<thead><tr>
							<td>操作</td>
							<td>统计日期</td>
							<td>点击量</td>
							<td>注册量</td>
							<td>提交认证量</td>
							<td>认证通过量</td>
							<td>下单人数</td>
							<td>下单总金额</td>
						</tr></thead>
						<tr>
							<td>修改前</td>
							<td>{{originalData.countDate}}</td>
							<td>{{originalData.clickCount}}</td>
							<td>{{originalData.registerCount}}</td>
							<td>{{originalData.applyCount}}</td>
							<td>{{originalData.applySuccessCount}}</td>
							<td>{{originalData.orderCount}}</td>
							<td>{{originalData.orderMoney}}</td>
						</tr>
						<tr class="modifyClass">
							<td>修改</td>
							<td>
								<Input type="text" v-model="originalData.countDate" readonly="readonly"></Input>
							</td>
							<td><Input type="text" v-model="updateList.clickCount"></Input></td>
							<td><Input type="text" v-model="updateList.registerCount"></Input></td>
							<td><Input type="text" v-model="updateList.applyCount"></Input></td>
							<td><Input type="text" v-model="updateList.applySuccessCount"></Input></td>
							<td><Input type="text" v-model="updateList.orderCount"></Input></td>
							<td><Input type="text" v-model="updateList.orderMoney"></Input></td>
						</tr>
					</table>
					<div style="float: right;margin-top:20px;text-align: right;">
					<Button type="primary" @click="updateDatePlatformData">确定</Button>
				</div>
				</div>
			</div>
		</div>
		<!-- 商户列表 end -->
		</div>
	</div>
</div>
<!-- 用户反馈 end -->
</template>

<script>
export default{
	data(){
		return{
			platformId:'',
			countDate:'',
			originalData:[],
			updateList:{
				countDate:'',
				clickCount:'',
				registerCount:'',
				applyCount:'',
				applySuccessCount:'',
				orderCount:'',
				orderMoney:''
			},
			platformList:[],
			loan_list_size: 1,
			loan_list_page: 1,
			loading: true,
			disDate: {
            	disabledDate (date) {
                 return date && date.valueOf() > Date.now();
                }
            }
		}
	},
	methods:{
		getDatePlatformData() {
			var _this = this;
			var param = {};
			param.platformId = _this.platformId;
			param.countDate = _this.countDate;
	    	this.$http.post('/helsinki/admin/daoliu/getDatePlatformData',param).then(function(res){
	    	if (res.data.errcode == 0) {
	        	_this.originalData = res.data.data.originalData == null ? {} : res.data.data.originalData;
	        	_this.updateList = res.data.data.confirmData == null ? {} : res.data.data.confirmData;
	        	_this.loan_list_size = res.data.data.size;
				_this.loan_list_page = param.pageIndex;
				_this.loading = false;
	    	}
	    	},function(res){
				_this.$Message.info(res.data.info);
			});
		},
		getAllPlatforms(){//获取所有平台
			var _this = this;
			this.$http.post('/helsinki/admin/daoliu/getAllPlatforms',{}).then(function(res){
	    	if (res.data.errcode == 0) {
	        	_this.platformList = res.data.data.list;
	    	}
	    	},function(res){
				_self.$Message.info(res.data.info);
			});
		},
		updateDatePlatformData(){
			var _this = this, param = {};
			param = _this.updateList;
			_this.updateList.countDate = _this.originalData.countDate;
			param.platformId =  _this.updateList.platformId == null ? _this.originalData.platformId : _this.updateList.platformId;
			this.$http.post('/helsinki/admin/daoliu/updateDatePlatformData',param).then(function(res){
	    	if (res.data.errcode == 0) {
	        	_this.$Message.info(res.data.info);
	    	}
	    	},function(res){
				_this.$Message.info(res.data.info);
			});
		},
		timeChange(e){
			if(typeof(e)=="object"){
				this.countDate = e[0];
				this.endDate = e[1];
			}else{
				this.countDate = e;
			}
			this.getDatePlatformData();
		},
		pageChange(e){
			this.getDatePlatformData(e);
		}
	},
	mounted:function(){
		this.getAllPlatforms();
		this.getDatePlatformData();
	},
	watch:{
		platformId:function(){
			this.getDatePlatformData();
		}
	}
}
</script>

<style>
	@import '../static/style.css';
	
	.modifyClass td input{
		text-align: center;
	}
</style>